package com.xiaoyun.service.impl.center;

import com.xiaoyun.bo.center.CenterUserBO;
import com.xiaoyun.mapper.UsersMapper;
import com.xiaoyun.pojo.Users;
import com.xiaoyun.service.center.CenterUserService;
import lombok.RequiredArgsConstructor;
import org.n3r.idworker.Sid;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class CenterUserServiceImpl implements CenterUserService {

    private final UsersMapper usersMapper;
    private final Sid sid;

    @Override
    public Users queryUserInfo(String userId) {
        Users users = usersMapper.selectByPrimaryKey(userId);
        return users;
    }

    @Override
    public Users updateUserInfo(String userId, CenterUserBO centerUserBO) {
        Users updateUsers = new Users();
        BeanUtils.copyProperties(centerUserBO, updateUsers);
        usersMapper.updateByPrimaryKeySelective(updateUsers);
        return queryUserInfo(userId);
    }

    @Override
    public Users updateUserFace(String userId, String faceUrl) {
        Users updateUsers = new Users();
        updateUsers.setId(userId);
        updateUsers.setFace(faceUrl);
        usersMapper.updateByPrimaryKeySelective(updateUsers);
        return queryUserInfo(userId);
    }
}
